using UnityEngine;

public class Laser : MonoBehaviour
{
	public LineRenderer laserbeam;

	public Transform startRaycastPoint;

	public Transform endLaser;

	private RaycastHit hit;

	public float maxLaserDistance;

	private Ray ray;

	private void FixedUpdate()
	{
		ray = new Ray(startRaycastPoint.position, startRaycastPoint.right);
		if (Physics.Raycast(ray, out hit, maxLaserDistance))
		{
			endLaser.transform.position = hit.point;
		}
		else
		{
			endLaser.transform.localPosition = new Vector3(maxLaserDistance, 0f, 0f);
		}
		laserbeam.SetPosition(0, startRaycastPoint.position);
		laserbeam.SetPosition(1, endLaser.position);
	}
}
